--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--[[



]]--
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
---
    local spell_fns = {
        ------------------------------------------------------------------
        --- 技能执行函数
            ["test_spell"] = function(inst,_table)
                if not inst.components.loramia_com_spell_controller:IsReady("test_spell") then
                    print("test_spell is running")
                    return
                end
                inst.components.loramia_com_spell_controller:StartTimer("test_spell",10)
            end,
        ------------------------------------------------------------------
        --- 节能模式
            ["energy_saving_mode"] = function(inst,_table)
                if not inst.components.loramia_com_spell_controller:NetGetData("energy_saving_mode") then
                    --- AddDebuff(name,prefab,data,skip_test,pre_buff_fn)
                    inst:AddDebuff("loramia_debuff_energy_saving_mode","loramia_debuff_energy_saving_mode")
                else
                    --- RemoveDebuff(name,skip_test,post_buff_fn)
                    inst:RemoveDebuff("loramia_debuff_energy_saving_mode")
                end
            end,
        ------------------------------------------------------------------
        --- 宇宙之翼
            ["wings_of_universe"] = function(inst,_table)
                inst:PushEvent("loramia_event.wings_of_universe_switch")
            end,
        ------------------------------------------------------------------
        --- 创造物冲击
            ["creation_impact"] = function(inst,_table)
                -- if not inst.components.loramia_com_spell_controller:IsReady("creation_impact") then
                --     print("creation_impact is running")
                --     return
                -- end
                -- inst.components.loramia_com_spell_controller:StartTimer("creation_impact",10)
                inst.components.loramia_com_item_spell_controller:StartSpell("loramia_spell_creation_impact")
            end,
        ------------------------------------------------------------------
        --- 创造物冲击
            ["life_mass_production"] = function(inst,_table)
                inst.components.loramia_com_item_spell_controller:StartSpell("loramia_spell_mass_production_for_life")
            end,
        ------------------------------------------------------------------
    }
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

return function(inst)
    if not TheWorld.ismastersim then
        return
    end


    inst:ListenForEvent("loramia_event.spell_ring_selected",function(inst,_table)
        _table = _table or {}
        local spell_name = _table.index
        print("spell ring selected",spell_name)
        if type(spell_name) ~= "string" then
            return
        end
        local fn = spell_fns[spell_name]
        if type(fn) == "function" then
            fn(inst,_table)
        end
    end)
    -------------------------------------------------------------------------------------------
    --- 节能模式 天赋解除
        inst:ListenForEvent("loramia_com_talent_tree_reset",function()
            inst:RemoveDebuff("loramia_debuff_energy_saving_mode")            
        end)
    -------------------------------------------------------------------------------------------

end